package com.wedata.致远接口;

import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.wedata.HttpUtils;

import java.util.Arrays;
import java.util.List;

public class 致远人员核对 {

    public static void main(String[] args) {
        getMembersByDept();
    }

    /**
     * 查询部门下的所有员工
     */
    public static void getMembersByDept() {
        //店播事业群--旗下所有人员
        String strss = "503,490913326112263524;522,7137608269679644256;523,-1271036413968956054;524,-3034793586246661226;533,2084631546866254901;534,4914483817122057535;";

        String[] strs = strss.split(";");
        StringBuffer phones = new StringBuffer();
        StringBuffer names = new StringBuffer();
        for (String param : strs){
            String[] ss =param.split(",");
            JSONArray depts = HttpUtils.getList(token.hostUrl + "/rest/orgMembers/department/"+ss[1]+"?token="+token.getToken());


            //System.out.println(depts.size());
            for(int i=0;i<depts.size();i++){
                JSONObject member = depts.getJSONObject(i);
                //System.out.println(member);
                //System.out.println(member.getStr("name")+"    "+member.getStr("telNumber")+"    "+param[0]+"    "+member.getStr("id"));
                phones.append("'").append(member.getStr("telNumber")).append("',");
                names.append("('").append(member.getStr("telNumber")).append("',").append("'").append(member.getStr("name")).append("'),");
                //System.out.println("update wedata_company_employee_info set seeyon_id="+member.getStr("id")+" where phone='" + member.getStr("telNumber")+"' and name='"+member.getStr("name")+"';");
                System.out.println("update wedata_company_employee_info a,wedata_company_emp_dept b set b.dept_id="+ss[0]+" where a.id=b.employee_id and b.deleted=0 and phone='" + member.getStr("telNumber")+"' and name='"+member.getStr("name")+"';");
            }

        }
        System.out.println(phones);
        System.out.println(names);
    }


}
